package cn.com.connext.scrm.repository.master;

import cn.com.connext.scrm.domain.master.ZnhjEntity;
import cn.com.connext.scrm.domain.master.ZnhjEntityTemp;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * @author zyk
 * Spring Data JPA repository for the Province entity.
 */
@Repository
public interface ZnhjEntityTempRepository extends JpaRepository<ZnhjEntityTemp, String>, JpaSpecificationExecutor {

    @Query(value = "select * FROM znhj_entity_temp where unique_code= :uniqueCode and bottle_code= :bottleCode and status = 1", nativeQuery = true)
    ZnhjEntity findByUniqueCodeAndBottomCode(@Param("uniqueCode") String uniqueCode, @Param("bottleCode") String bottleCode);

    @Modifying
    @Query(value = "update znhj_entity_temp set  status = :status where id in (:ids)", nativeQuery = true)
    void batchUpdate(@Param("ids") List<String> ids, @Param("status") String status);
}
